package logic_setting_role

import (
	v1 "Sailor/app/Sailor-console-server/api/api_setting_role/v1"
	"Sailor/app/Sailor-console-server/internal/dao"
	"Sailor/app/Sailor-console-server/internal/model/entity"
	"context"
	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
)

func (s *sSettingRole) LogicSettingRoleListAll(ctx context.Context, req *v1.SettingRoleListAllReq) (res *v1.SettingRoleListAllRes, err error) {

	var roles []entity.SysRole
	err = dao.SysRole.Ctx(ctx).Scan(&roles)
	if err != nil {
		g.Log().Error(ctx, err)
		return nil, gerror.New("获取失败")
	}
	newRes := append(v1.SettingRoleListAllRes{}, roles...)
	return &newRes, nil

}
